/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package trackreggui.swing;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import javax.swing.TransferHandler.TransferSupport;
import webreg.model.Disciplin;


/**
 *
 * @author STKNOLL
 */
public class DisciplinTransferable implements Transferable {
    private Disciplin mToTransfer;

    public DisciplinTransferable(Disciplin inDisciplin) {
        mToTransfer = inDisciplin;
    }
    
    public DataFlavor[] getTransferDataFlavors() {
        System.out.println("GUI: getTransferDataFlavors");
        DataFlavor[] retVal = { getFlavor() };
        return retVal;
    }
    
    public boolean isDataFlavorSupported(DataFlavor arg0) {
        System.out.println("GUI: isDataFlavorSupported");
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Object getTransferData(DataFlavor arg0) throws UnsupportedFlavorException, IOException {
        System.out.println("GUI: getTransferData");
        if ( ! arg0.equals( getFlavor() ) ) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
        return mToTransfer;
    }

    public static DataFlavor getFlavor() {
        String disciplinClassName = Disciplin.class.getName();
        return new DataFlavor(Disciplin.class, DataFlavor.javaJVMLocalObjectMimeType + ";class=" + disciplinClassName);
    }
}
